Make tests a little more robust
authorAlex Crichton <alex@alexcrichton.com>
Mon, 1 Feb 2016 18:02:04 +0000 (10:02 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 1 Feb 2016 18:02:04 +0000 (10:02 -0800)
* Remove the XDG_CONFIG_HOME environment variable as we're resetting HOME
* Add GIT_CONFIG_NOSYSTEM to encourage git to not read that configuration

Closes #2345

tests/test_cargo_new.rs
tests/tests.rs

index 63868112fcd869018eeab6be21ed96306ead8706..2c97ba9aae9a01de48e5997953e7ee7bc7561b76 100644 (file)
@@ -12,12 +12,6 @@ use cargo::util::{process, ProcessBuilder};
 fn setup() {
 }
 
-fn my_process(s: &str) -> ProcessBuilder {
-    let mut p = process(s);
-    p.cwd(&paths::root()).env("HOME", &paths::home());
-    return p;
-}
-
 fn cargo_process(s: &str) -> ProcessBuilder {
     let mut p = ::cargo_process();
     p.arg(s);
@@ -188,10 +182,10 @@ test!(finds_author_email {
 });
 
 test!(finds_author_git {
-    my_process("git").args(&["config", "--global", "user.name", "bar"])
-                     .exec().unwrap();
-    my_process("git").args(&["config", "--global", "user.email", "baz"])
-                     .exec().unwrap();
+    ::process("git").args(&["config", "--global", "user.name", "bar"])
+                    .exec().unwrap();
+    ::process("git").args(&["config", "--global", "user.email", "baz"])
+                    .exec().unwrap();
     assert_that(cargo_process("new").arg("foo").env("USER", "foo"),
                 execs().with_status(0));
 
@@ -202,10 +196,10 @@ test!(finds_author_git {
 });
 
 test!(author_prefers_cargo {
-    my_process("git").args(&["config", "--global", "user.name", "foo"])
-                     .exec().unwrap();
-    my_process("git").args(&["config", "--global", "user.email", "bar"])
-                     .exec().unwrap();
+    ::process("git").args(&["config", "--global", "user.name", "foo"])
+                    .exec().unwrap();
+    ::process("git").args(&["config", "--global", "user.email", "bar"])
+                    .exec().unwrap();
     let root = paths::root();
     fs::create_dir(&root.join(".cargo")).unwrap();
     File::create(&root.join(".cargo/config")).unwrap().write_all(br#"
index 8eb5f5aa75338100a376fcb0626b8ca2721d619d..a9ec84adc2239a455066de79705cb3f97ea6fe4c 100644 (file)
@@ -90,8 +90,10 @@ fn process<T: AsRef<OsStr>>(t: T) -> cargo::util::ProcessBuilder {
     p.cwd(&support::paths::root())
      .env("HOME", &support::paths::home())
      .env_remove("CARGO_HOME")
-     .env_remove("CARGO_TARGET_DIR") // we assume 'target'
-     .env_remove("MSYSTEM");    // assume cmd.exe everywhere on windows
+     .env_remove("XDG_CONFIG_HOME")      // see #2345
+     .env("GIT_CONFIG_NOSYSTEM", "1")    // keep trying to sandbox ourselves
+     .env_remove("CARGO_TARGET_DIR")     // we assume 'target'
+     .env_remove("MSYSTEM");             // assume cmd.exe everywhere on windows
     return p
 }